package com.itsu.shirojwt.shiro.credentialsMatcher;

import com.itsu.shirojwt.utils.JWTUtil;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.CredentialsMatcher;

public class JWTCredentialsMatcher implements CredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        String tokenStr = (String) token.getCredentials();
        String primaryPrincipal = (String) info.getPrincipals().getPrimaryPrincipal();
        String credentials = (String) info.getCredentials();
        boolean res = JWTUtil.verify(tokenStr, credentials);
        return res;
    }

}